from django.contrib import admin

# Register your models here.
from django.contrib import admin
from .models import Device  # 👈 从当前 app 的 models.py 导入 Device
 
@admin.register(Device)     # 👈 装饰器：注册 Device 模型到 Admin
class DeviceAdmin(admin.ModelAdmin):  # 👈 继承 ModelAdmin，自定义后台行为
    list_display = ['name', 'device_type', 'purchase_date', 'under_warranty']
    list_filter = ['device_type', 'under_warranty']
    search_fields = ['name', 'notes']
    date_hierarchy = 'purchase_date'
    ordering = ['-purchase_date']  # 按购买日期倒序
